package com.mall.inventory.server.controller;

import com.mall.common.core.domain.Result;
import com.mall.inventory.common.Idempotent;
import com.mall.inventory.common.dto.CmsPurchaseOrderDto;
import com.mall.inventory.common.dto.CmsPurchasePlanDto;
import com.mall.inventory.common.po.CmsPurchasePlan;
import com.mall.inventory.server.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/inventory")
public class InventoryController {


    @Idempotent("paymentOperation")
    public void processPayment(String paymentId) {
        // 处理支付逻辑
    }


    @Autowired
    private InventoryService inventoryService;

    /**
     * 添加采购计划
     *
     * @param skuIds
     * @return
     */
    @PostMapping("/addCmsPurchasePlan")
    public Result addCmsPurchasePlan(String skuIds) {
        return Result.success(inventoryService.addCmsPurchasePlan(skuIds));
    }

    /**
     * 添加采购订单
     *
     * @param cmsPurchaseOrderDto
     * @return
     */
    @PostMapping("/addPurchaseOrder")
    public Result addPurchaseOrder(@RequestBody CmsPurchaseOrderDto cmsPurchaseOrderDto) {
        return Result.success(inventoryService.addPurchaseOrder(cmsPurchaseOrderDto));
    }

    /**
     * 审核采购计划
     *
     * @param cmsPurchasePlan
     * @return
     */
    @PostMapping("/updatePlan")
    public Result updatePlan(@RequestBody CmsPurchasePlan cmsPurchasePlan) {
        return Result.success(inventoryService.updatePlan(cmsPurchasePlan));
    }


    /**
     * 查询低库存列表
     *
     * @param
     * @return
     */
    @GetMapping("/getSkuInfoList")
    public Result getSkuInfoList() {
        return inventoryService.getSkuInfoList();
    }

    /**
     * 查询采购计划列表
     *
     * @param planStatus
     * @return
     */
    @GetMapping("/CmsPurchasePlanList")
    public Result CmsPurchasePlanList(Integer planStatus) {
        return inventoryService.CmsPurchasePlanList(planStatus);
    }
}
